namespace SearchEngine
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string str = textBox1.Text;
            str = str.Replace(" ","%20");

            Crawlerpro cra1 = new Crawlerpro();
            Crawlerpro cra2 = new Crawlerpro();

            cra1.startRef = "http://www.baidu.com/s?wd=" + str;
            cra2.startRef = "http://www.baidu.com/s?wd=" + str;

            Thread thread1 = new Thread(cra1.Crawl);
            Thread thread2 = new Thread(cra2.Crawl);
            
            thread1.Start();
            thread2.Start();

            while (true)
            {
                if ((!thread1.IsAlive) && (!thread2.IsAlive))
                {
                    textBox2.Text = cra1.endRef;
                    textBox3.Text = cra2.endRef;
                    break;
                }
            }
            
            //new Thread(baidu.Crawl).Start();
            //new Thread(baidu.Crawl).Start();
            //textBox2.Text = baidu.R1;
            //textBox3.Text = baidu.R2;
        }
    }
}